package com.unicom.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import com.unicom.config.IStoryCore;
import com.unicom.request.GetCommentRequest;
import com.unicom.response.GetCommentResponse;
import com.unicom.utils.StoryListener;

public class TaskGetComment extends AbstractTask{
	private String authenKey;
	private String Schedule_id;
	private String pageLimit;
	private String pageNumber;
	
	
	public TaskGetComment(StoryListener listener, IStoryCore core,
			String authenKey, String schedule_id, String pageLimit,
			String pageNumber) {
		super(listener, core);
		this.authenKey = authenKey;
		this.Schedule_id = schedule_id;
		this.pageLimit = pageLimit;
		this.pageNumber = pageNumber;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException, IOException {
		GetCommentRequest request = new GetCommentRequest();
		request.setAuthenKey(authenKey);
		request.setSchedule_id(Schedule_id);
		request.setPageNumber(pageNumber);
		request.setPageLimit(pageLimit);
		GetCommentResponse response = protocol.getComment(request);
		for (StoryListener mlistener : listener){
			mlistener.finishGetComment(response.getReturnCode(), response.getResultMsg(), response.getRecordNumber(), response.getCountPage(), response.getListComment());
		}
	}

	@Override
	public void timeoutCallback() {
		for (StoryListener mlistener : listener){
			mlistener.finishGetComment(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "", 0, 0, null);
		}
	}

}
